

	Special features in x64 emulation
	----- X64 version 0.2. PL 2 -----

  Introduction to the X64 system on the hardware and compability point
  of view.



  DETAILS OF EMULATION


  6510 Features

	JMP($indirect) doesn't have the wrap-aroud bug
	Clock cycle count is not fixed when page boundary crossing or
	 conditional branch occurs
	RMW instructions don't write data back at incorrect address first.
	Undocumented comands are fixed to the most common behaviour.
	Any information on incompability is welcome.


  6502 Undocumented Mnemonic Dialects

  Separate C64 user groups use different mnemonics for the undocumented
  opcodes. The ones selected for x64 are from the most widely known set,
  except few deviations for clarity.


      Opcode	x64	C=Hacking,    C64	  J West     Expose
			C-Lehti	      Konekieli

	0b,2b	ANC			 -	    ALC		ANA
	8b	ANE			 -	    XAN		XMA
	6b	ARR			 -	    RAR		RAM
	4b	ASR			 -	    SAR		RBM
		DCP			DCMP
		ISB			ISBC	    ISC
	x2	JAM			 -	    HLT		CRS
	bb	LAS	   LAE		 -	    SAM
		LAX			LDAX	    LXA
	ab	LXA			 -	    LAX		AMA
		NOOP	   NOP		 -			SKP
		RLA			RLAN			LAN
		RRA			RRAD			RAD
		SAX			STAX			AAX
		SBX			 -			AXM
	93,9f	SHA			????	    STR		TEA
	9b	SHS			 -	    SRS		AXS
	9e	SHX			????	    XAM		TEX
	9c	SHY			 -	    YAM		TEY
		SLO			SLOR			LOR
		SRE			SREO	    LSE		REO
	eb	USBC	   SBC		 -	    SBC		SBC


	Empty column means mnemonic is identical to the x64 one.





  Screen and VIC

  Limited support. All text modes, simple graphics.
  Doen't support rasterline effects not ecxessive screen activity.


  Sound, SID

  Not supported.


  Peripherals and Add-ons

  The most common peripherals, ie printers and 1541 disk drives are
  included in the emulation. There is no CPU for the disk drive.

  X64 supports both RAM expansion and game cartridges.
  It is even possible to change between different kernel versions.


  X64 Traps

  Traps are wedges to the operating system for better performance. They
  are marked by writing a zero (BRK instruction) into the address where
  the execution has to be directed to an replacement routine.


Type	Name		Kernel Routine			Address	 Checkbytes

 * Kernel idle traps

TRAP	trap_idle_E5D4					E5D4	F0 F7 78


 * Serial module traps.  

  The serial device interface consists of traps in serial access routines
  TALK, ACPTR, Send Data, and Get Data, so that actual operation can be
  controlled by C routines.  Serial.c implements the I/F control whereas
  the required acknowledge is supplied with the peripheral emulators.
  To support turboloaders, it would be necessary to emulate the serial port
  itself. That is much slower though. :(


TRAP	SerialListen	TALK: send TALK/LISTEN		ED0E	20 A4 F0

TRAP	SerialSaListen	TALK				ED36	78 20 8E

TRAP	SerialSendByte	Send Data on Serial Bus		ED40	78 20 97

TRAP	SerialReceiveByte
			ACPTR: receive from serial bus	EE13	78 A9 00

Return	SERIAL_RTS	Send Data on Serial Bus		EDAC

 * Disk drive traps

TRAP	1541 Ready	Get serial data and clk in	EEA9	AD 00 DD

Return			Get serial data and clk in	EEB2



  FILE COMPABILITY

  X64 provides complete backward compability, but the implementation of new
  operating modes requires system files that are not interchangeable. There
  must be separate RAM and ROM (including modules) images for each program.
  The RAM expansion and disk images are the same.

  However, as there are several emulators for different platforms, they all
  cannot be made directly usable. Utilities to convert those back into CBM
  binary exist already.

  Below is description of the most common file formats. some of them are
  supported, the others are just for reference.


  X64 Ram File		Total Size: RAMSIZE + 4103

  Upon startup x64 searches for a file called "ram", containing the RAM
  memory from a previous run. If one is not available, a cold start (the
  normal power boot-up) is required. A ram image from clean run (not eg.
  a freezed demo) is, however a vital resource for advanced use of x64,
  since it makes possible to skip the RESET sequence.
  The inbuilt monitor treats this file somewhat differently, since it
  also saves and restores the state of I/O area as well as the 6510
  registers. That makes it possible to use so called snapshot images.

      Offset	Bytes	 Description

	 0	RAMSIZE	 contents of the RAM
     RAMSIZE	4096	 I/O area with shadows
		 7	 CPU Registers: PC (LO/HI), AC, XR, YR, PS, SP



  X64 Disk File		Total Size: 174912

      Offset	Bytes	Description

	 0	 4	Magic header: 'C',0x15, 0x41, 0x64

	 4	 4	Header Version:
			   C1541 Version Major
			   C1541 Version Minor
			   Device Type:	0 = 1541
			   Max Tracks:	35  (from disks v1.2 upwards)

	64		256 byte sectors



  *.d64 disk File	Total Size: 174878

  The C64S disk images consist of only the binary data for sectors and
  they can be converted into the right format with c1541 via -c option.


  Tape File		Total Size: Varies

    *.t64 tape image

  X64 does NOT use any tape images, but c1541 can be used to copy to a
  disk image files from *.t64 tape images that follow this structure:

      Offset	Bytes	Description

	 0		64 byte Tape Record:
	 0	32	Tape description
	32	 2	Tape version: $0100
	34	 2	Max number of files, in LO/HI
	36	 2	Number of existing files, in LO/HI
	38	 2	 -
	40	24	User description

	64		32 byte Directory Slots for each file:
	 +0	1	Slot allocation flag:
			  00 = free entry
			  01 = normal tape file
			  02..FF = memory snapshots
	 +1	 1	File type
	 +2	 2	Start address in C64 memory, in LO/HI
	 +4	 2	End address in C64 memory, in LO/HI
	 +6	 2	 -
	 +8	 4	File start address on the image, in LO/HI
	+12	 4	 -
	+16	16	C64 filename


  Program File		Total Size: Varies

    CBM Files

  X64 uses the standars CBM program files containing load address in
  the first two bytes.

    *.P00

  This is program file for the 64NEU. Not supported.
  To extract the original, remore the first 26 bytes.

      Offset	Bytes	Description

	 0	 9	String "C64File" terminated by 00.
	 9	17	Original C64 Filename.
	10	 1	Record size for REL files.
	26		Original file



  ACKNOWLEDGEMENTS

  The compability section is based on the information acquired from
  news articles written by:
	blohm@mathematik.uni-ulm.de (Guntram Blohm)
	kbrisley@tsegw.tse.com      (Kevin Brisley)

